
*********************************************************************************************************************
****** Replication dofile **
*** "Brokering bureaucrats: How bureaucrats and civil society facilitate clientelism where parties are weak" ***
*** Agnes Cornell and Marcia Grimes *** 
*** Comparative Political Studies ***
*********************************************************************************************************************

*Stata
version 17
*Datafile
use "Replicationdata_Brokering_bureaucrats_Cornell_Grimes.dta"

*** Recoding of variables from dataset on bureaucrats in regional governments in Peru ***
******************************************************************************************

*Voter mobilization (polact_moreac_rowmean)
egen polact_moreac_rowmean=rowmean(eg_P50 eg_P51 eg_P52 P53 eg_P54)

*Citizens' request (cit_req)
gen P23_dummy=eg_P23
replace P23_dummy=0 if eg_P23==2
replace P23_dummy=0 if eg_P23==3

gen cit_req=P23_dummy
replace cit_req=0 if eg_P22==5 & P23_dummy==.

*Civil society connections (eg_P10_someexp) 
gen eg_P10_someexp=.
replace eg_P10_someexp=0 if eg_P10==9
recode eg_P10_someexp (.=1) if eg_P10<5

*Political connections (eg_P14_someexp)
gen eg_P14_someexp=.
replace eg_P14_someexp=0 if eg_P14==9
recode eg_P14_someexp (.=1) if eg_P14<5

*Party member (partmovmemb)
gen partymemb=.
replace partymemb=1 if P55==1
replace partymemb=1 if P55==2
replace partymemb=0 if P55==3
replace partymemb=0 if P55==4

gen movmemb=.
replace movmemb=1 if P56==1
replace movmemb=1 if P56==2
replace movmemb=0 if P56==3
replace movmemb=0 if P56==4

gen partmovmemb=0
replace partmovmemb=1 if partymemb==1
replace partmovmemb=1 if movmemb==1
replace partmovmemb=. if partymemb==. & movmemb==.

*Gender (eg_gender)
gen eg_gender=eg_P2
replace eg_gender=0 if eg_P2==2

*Years employed in regional government (years_govreg)
gen years_govreg=2016-P5

*Frontline bureaucrat (cit_ser)
gen cit_ser=.
replace cit_ser=0 if eg_P7<.
replace cit_ser=1 if eg_P7==3

*University education (eg_ed_univ)
gen eg_ed_univ=.
replace eg_ed_univ=0 if eg_P3<7
replace eg_ed_univ=1 if eg_P3>6 
replace eg_ed_univ=. if eg_P3==.

*Composite indicator of brokerage (comp_brokerage)
gen comp_brokerage=polact_moreac_rowmean*cit_req 

*Secure tenure (permanent) (same as dummy for civil service contract Law 276, Adm. Career 276)
gen permanent=1 if eg_P8A==1
replace permanent=0 if eg_P8A<. & permanent==.

****Recoding of regional variables from other sources (see end of do-file for how to merge and construct the variables from other sources)***

*Civil society strength at regional level
gen per_civic=enaho_not_parties_any_part*100

*Electoral volatility (mean)
egen mean_elvol=rowmean(vol_el_vol_02_06 vol_el_vol_06_10 vol_el_vol_10_14)

*Population in thhousands
gen pop_2015_thousand=population_2015/1000
gen new_pop_2015_thousands=pop_2015_thousand
replace new_pop_2015_thousands=8890.792 if region_code==1501
replace new_pop_2015_thousands=9834.631-8890.792 if region_code==15

*Ln(GDP per capita)
gen PBI_cap=PBI_2015/new_pop_2015_thousands
replace PBI_cap=PBI_cap/1000
label variable PBI_cap "PBI capita 2015"
gen ln_PBI_cap=ln(PBI_cap)

*Regional budget per capita
gen pim_cap=PIM2015MillonesS/new_pop_2015_thousands


*******Tables and Figures and other calculations in main manuscript*******
**************************************************************************


*Section Politics and public administration in Peruvian regions: "Question about the importance of political connections"*
tab P28

*Section Politics and public administration in Peruvian regions: "Question on what proportion of the employees bureaucrats estimate would be replaced" (values 5-10 above 50%)*
tab eg_P59

*Section Politics and public administration in Peruvian regions: "% of respondents with permanent tenure"*
tab permanent

*Section Research design and data: "About 33% of all public sector employees in the ENAHO data from 2015 have jobs like those included in our survey"*
*use data from ENAHO described below for APPENDIX B4
*tab bureaucrat if p510==2


*Section Results, first pararaph*
pwcorr eg_P10_someexp eg_P14_someexp, sig
pwcorr partmovmemb eg_P14_someexp, sig


****TABLE 1. Individual connections and brokering behavior****
eststo:xtreg polact_moreac_rowmean eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg polact_moreac_rowmean eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

eststo:xtreg cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

esttab using table1.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

****Predicted values in section "Individual bureaucrats' connections and brokering behavior"****
xtreg polact_moreac_rowmean eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
margins, asbalanced atmeans at(eg_P10_someexp=(0 1))
margins, asbalanced atmeans at(partmovmemb=(0 1))

****Figure 2. Predicted values: Voter mobilization index****
xtreg polact_moreac_rowmean eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
margins, asbalanced atmeans at(eg_P10_someexp=0 partmovmemb=0 eg_P14_someexp==0) at(eg_P10_someexp=1 partmovmemb=0 eg_P14_someexp=0) at(eg_P10_someexp=0 partmovmemb=1 eg_P14_someexp=0) at(eg_P10_someexp=1 partmovmemb=1 eg_P14_someexp=0) at (eg_P10_someexp=0 partmovmemb=0 eg_P14_someexp==1) at(eg_P10_someexp=1 partmovmemb=0 eg_P14_someexp=1) at(eg_P10_someexp=0 partmovmemb=1 eg_P14_someexp=1) at(eg_P10_someexp=1 partmovmemb=1 eg_P14_someexp=1) 
marginsplot, recast(scatter)

****Predicted probability of citizens' request based on model 3, Table A3****
clogit cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed years_govreg cit_ser i.eg_P9 i.eg_P8A, group(region_code) cluster(region_code) 
margins, asbalanced atmeans at(eg_P10_someexp=0 eg_P10_someexp=1)

****Predicted values based on model 2, Table A4****
xtreg polact_moreac_rowmean i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9, fe cluster(region_code)
margins, asbalanced atmeans at(eg_P10_someexp=0 permanent=0) at(eg_P10_someexp=1 permanent=0) at(eg_P10_someexp=0 permanent=1) at(eg_P10_someexp=1 permanent=1)

*****Predicted values based on model 2, Table A7****
xtreg polact_moreac_rowmean cit_req eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
margins, asbalanced atmeans at(cit_req=1 cit_req=0)

****Predicted probability based on model 2, Table A8****
clogit cit_req polact_moreac_rowmean eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, group(region_code) cluster(region_code) 
sum polact_moreac_rowmean if e(sample)==1
margins, asbalanced atmeans at(polact_moreac_rowmean=1 polact_moreac_rowmean=2.2 polact_moreac_rowmean=7)

******Correlation civil society strength and strength of parties******
pwcorr per_civic mean_elvol, sig

****Figure 3. Civil society strength by region****
graph bar per_civic, over(Region)

****Figure 4. Regional variation in electoral volatility****
graph bar mean_elvol, over(Region)

****Table 2. Voter mobilization and citizens' requests: Political connections, civil society strength****
eststo:mixed polact_moreac_rowmean eg_P14_someexp per_civic || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req eg_P14_someex per_civic || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 

esttab using table2.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table 3. Predicted probabilites of citizens' requests****
melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 
margins, asbalanced atmeans predict(mu fixedonly) at(eg_P14_someexp=(0 1) per_civic=(15 56 87))

****Figure 5. Conditional marginal effects of political conenctions on citizens' requests****
margins , dydx(eg_P14_someexp) asbalanced atmeans predict(mu fixedonly) at(per_civic=(15(1)87))
marginsplot, graphregion(fcolor(white)) plotregion(fcolor(white)) ciopts(lcolor(black) lpattern(dash)) recastci(rline) recast(line) 

*clear

*******ONLINE APPENDIX****************************************************
**************************************************************************


******* Appendix B4. Representativeness of the survey *******
*************************************************************

**Data from ENAHO 2015 (Enguesta Nacional de hogares sobre condiciones de vida y pobreza) download of modules: 498_Modulo02/enaho01-2015-200, 498-Modulo03/enaho01a-2015-300, and 498-Modulo05/enaho01a-2015-500 from INEI at http://webinei.inei.gob.pe/anda_inei/index.php/catalog/276/get_microdata 

**MERGE OF DATASET FROM ENAHO 2015
*use "/INEI/498_Modulo02/enaho01-2015-200.dta"

*merge 1:1 conglome vivienda hogar codperso ubigeo using "/INEI/498-Modulo03/enaho01a-2015-300.dta"

*drop _merge

*merge 1:1 conglome vivienda hogar codperso ubigeo using "/INEI/498-Modulo05/enaho01a-2015-500.dta"
*drop _merge

*destring ubigeo, replace

*gen Region=0
*replace Region=1 if ubigeo<20000
*replace Region=2 if ubigeo>19999 & ubigeo<30000
*replace Region=3 if ubigeo>29999 & ubigeo<40000
*replace Region=4 if ubigeo>39999 & ubigeo<50000
*replace Region=5 if ubigeo>49999 & ubigeo<60000
*replace Region=6 if ubigeo>59999 & ubigeo<70000
*replace Region=7 if ubigeo>69999 & ubigeo<80000
*replace Region=8 if ubigeo>79999 & ubigeo<90000
*replace Region=9 if ubigeo>89999 & ubigeo<100000
*replace Region=10 if ubigeo>99999 & ubigeo<110000
*replace Region=11 if ubigeo>109999 & ubigeo<120000
*replace Region=12 if ubigeo>119999 & ubigeo<130000
*replace Region=13 if ubigeo>129999 & ubigeo<140000
*replace Region=14 if ubigeo>139999 & ubigeo<150000
*replace Region=15 if ubigeo>149999 & ubigeo<160000

*Lima Metropolitana
*replace Region=1501 if Region==15 & ubigeo>150000 & ubigeo<150200

*replace Region=16 if ubigeo>159999 & ubigeo<170000
*replace Region=17 if ubigeo>169999 & ubigeo<180000
*replace Region=18 if ubigeo>179999 & ubigeo<190000
*replace Region=19 if ubigeo>189999 & ubigeo<200000
*replace Region=20 if ubigeo>199999 & ubigeo<210000
*replace Region=21 if ubigeo>209999 & ubigeo<220000
*replace Region=22 if ubigeo>219999 & ubigeo<230000
*replace Region=23 if ubigeo>229999 & ubigeo<240000
*replace Region=24 if ubigeo>239999 & ubigeo<250000
*replace Region=25 if ubigeo>249999 & ubigeo<260000

*Create a new variable for bureaucrat
*gen bureaucrat=.

*replace bureaucrat=1 if p505==112 |p505==127 | p505==137 | p505==143  | p505==217 | p505==218 | p505==219 | p505==221 | p505==222 | p505==225 | p505==226 | p505==227 | p505==228 | p505==229   | p505==231 | p505==234 | p505==237 | p505==251 | p505==252 | p505==254 | p505==255 | p505==256 | p505==258 | p505==261 | p505==262 | p505==263 | p505==264 | p505==266 | p505==269 | p505==311 | p505==312 | p505==313 | p505==314 | p505==317| p505==318| p505==319 | p505==321 | p505==335 | p505==341  | p505==342 | p505==344 | p505==345 | p505==349 |p505==364 | p505==366 | p505==375 | p505==377 | p505==381 | p505==382 | p505==383| p505==391 |p505==411 | p505==412 | p505==413 | p505==415 | p505==418 | p505==419 | p505==421 | p505==423 | p505==442|  p505==451 | p505==453 | p505==454 | p505==461 | p505==462 | p505==582 

*replace bureaucrat=0 if p510==1
*replace bureaucrat=0 if p510==3
*replace bureaucrat=0 if p510==5
*replace bureaucrat=0 if p510==6
*replace bureaucrat=0 if p510==7
*replace bureaucrat=0 if p510==2 & bureaucrat==.

*Gender
*gen gender=p207
*replace gender=0 if p207==2

*University education
*gen encuest_ed_univ=.
*replace encuest_ed_univ=0 if p301a<9
*replace encuest_ed_univ=1 if p301a>8
*replace encuest_ed_univ=. if p301a==.

*CAS contract
*gen CAS=.
*replace CAS=0 if p511a<.					  
*replace CAS=1 if p511a==6	

**save replication_data_enaho.dta

********TABLE B4.1 Bureaucrats in BRG and ENAHO******
*ENAHO Bureaucrats (mean)
*sum gender p208a encuest_ed_univ p513a1 CAS if bureaucrat==1

*clear


*BRG (mean)
*Data from survey of bureaucrats in regional governments (BRG)

*use "Replicationdata_Brokering_bureaucrats_Cornell_Grimes.dta"


*Age
gen age=.
replace age=2016-P1

*Years employment at the same position
gen years_worked_same=.
replace years_worked_same=2016-P6

*CAS
gen CAS=.
replace CAS=0 if eg_P8A<.
replace CAS=1 if eg_P8A==3

sum eg_gender age eg_ed_univ years_worked_same CAS

*One sample T-test

ttest eg_gender == 0.61
ttest age == 42.52
ttest eg_ed_univ == 0.58
ttest years_worked_same == 8.56
ttest CAS == 0.16

*clear

********TABLE B4.2: Only CAS: Bureaucrats in BRG and ENAHO******
*use replication_data_enaho.dta
*ENAHO Bureaucrats (mean)
*sum gender p208a encuest_ed_univ p513a1 if bureaucrat==1 & CAS==1

*clear
**BRG (mean)
*Data from survey of bureaucrats in regional governments (BRG)

sum eg_gender age eg_ed_univ years_worked_same if CAS==1

*One sample T-test
ttest eg_gender == 0.48 if CAS==1
ttest age == 37.05 if CAS==1
ttest eg_ed_univ == 0.69 if CAS==1
ttest years_worked_same == 3.24 if CAS==1

***Appendix A************************************************
*************************************************************


****TABLE A1: Summary statistics****
sum polact_moreac_rowmean cit_req  eg_P10_someexp eg_P14_someexp partmovmemb eg_gender years_govreg cit_ser eg_ed_univ comp_brokerage i.eg_P9 i.eg_P8A ///
per_civic vol_el_vol_10_14 mean_elvol new_pop_2015_thousands ln_PBI_cap pim_cap 


****Table A2: Voter mobilization and citizens' request****
eststo:xtreg polact_moreac_rowmean eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
eststo:xtreg cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
esttab using tableA2.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

****TABLE A3. Individual factors and citizens' requests with conditional fixed effects logistic regression****
eststo:clogit cit_req eg_P10_someexp eg_P14_someexp, group(region_code) cluster(region_code) 
eststo:clogit cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, group(region_code) cluster(region_code) 
eststo:clogit cit_req eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, group(region_code) cluster(region_code) 

esttab using tableA3.rtf, constant aic bic scalars(ll) b(3) se replace
eststo clear

****Table A4. Individual connections in interaction with secure tenure****
eststo:xtreg polact_moreac_rowmean i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg polact_moreac_rowmean i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9, fe cluster(region_code)

eststo:xtreg cit_req i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg cit_req i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9, fe cluster(region_code)

esttab using tableA4.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

****Table A5. Individual connections in interaction with secure tenure with conditional fixed effects logistic regression****
eststo:clogit cit_req i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser, group(region_code) cluster(region_code) 
eststo:clogit cit_req i.eg_P10_someexp##i.permanent i.eg_P14_someexp##i.permanent i.partmovmemb##i.permanent eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9, group(region_code) cluster(region_code) 

esttab using tableA5.rtf, constant aic bic scalars(ll) b(3) se replace
eststo clear


****Table A6. Individual connections and brokering behavior: Composite indicator****
eststo:xtreg comp_brokerage eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg comp_brokerage eg_P10_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

esttab using tableA6.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

****Table A7. Test of brokerage variables****
eststo:xtreg polact_moreac_rowmean cit_req eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg polact_moreac_rowmean cit_req eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)
eststo:xtreg cit_req polact_moreac_rowmean eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg cit_req polact_moreac_rowmean eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

esttab using tableA7.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

****Table A8. Test of brokering variables with conditional fixed effects logistic regression****
eststo:clogit cit_req polact_moreac_rowmean eg_gender eg_ed_univ years_govreg cit_ser, group(region_code) cluster(region_code) 
eststo:clogit cit_req polact_moreac_rowmean eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, group(region_code) cluster(region_code) 

esttab using tableA8.rtf, constant aic bic scalars(ll) b(3) se replace
eststo clear

*****Table A9. Interactions with brokering to explain another form of brokering****
eststo:xtreg polact_moreac_rowmean i.cit_req##i.eg_P10_someexp i.cit_req##i.eg_P14_someexp i.cit_req##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg polact_moreac_rowmean i.cit_req##i.eg_P10_someexp i.cit_req##i.eg_P14_someexp i.cit_req##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

eststo:xtreg cit_req c.polact_moreac_rowmean##i.eg_P10_someexp c.polact_moreac_rowmean##i.eg_P14_someexp c.polact_moreac_rowmean##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, fe cluster(region_code)
eststo:xtreg cit_req c.polact_moreac_rowmean##i.eg_P10_someexp c.polact_moreac_rowmean##i.eg_P14_someexp c.polact_moreac_rowmean##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, fe cluster(region_code)

esttab using tableA9.rtf, replace r2 ar2 aic bic se b(3)
eststo clear

*****Table A10. Interactions with voter mobilization explaining citizens' requests (conditional fixed effects logistic regression)*****
eststo:clogit cit_req c.polact_moreac_rowmean##i.eg_P10_someexp c.polact_moreac_rowmean##i.eg_P14_someexp c.polact_moreac_rowmean##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser, group(region_code) cluster(region_code) 
eststo:clogit cit_req c.polact_moreac_rowmean##i.eg_P10_someexp c.polact_moreac_rowmean##i.eg_P14_someexp c.polact_moreac_rowmean##i.partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A, group(region_code) cluster(region_code) 

esttab using tableA10.rtf, constant aic bic scalars(ll) b(3) se replace
eststo clear

*****Table A11. Voter mobilization: Civil society connections, strength of civil society*****
eststo:mixed polact_moreac_rowmean eg_P10_someexp per_civic || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , stddev  cluster(region_code)
**With regional controls
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)

esttab using A11.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A12. Citizens' request: Civil society connections, strength of civil society*****
eststo:melogit cit_req eg_P10_someexp per_civic || region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
**With regional controls
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: , vce(cluster region_code) 

esttab using tableA12.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A13. Voter mobilization: Civil society connections, strength of civil society (exclusion of Lima Metropolitana or Callao)******
*Without Lima Metropolitana
eststo:mixed polact_moreac_rowmean eg_P10_someexp per_civic if region_code!=1501 || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic  if region_code!=1501 || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp ///
partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: , stddev cluster(region_code)
*Without Callao
eststo:mixed polact_moreac_rowmean eg_P10_someexp per_civic if region_code!=7 || region_code: ,  stddev cluster(region_code)
estat icc 
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic  if region_code!=7 || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=7 || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.per_civic eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev cluster(region_code)

esttab using tableA13.rtf, replace constant aic bic scalars(ll)  b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A14. Citizens' request: Civil society connections, strength of civil society (exclusion of Lima Metropolitana or Callao)******
*Drop Lima Metropolitana 
eststo:melogit cit_req eg_P10_someexp per_civic if region_code!=1501|| region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic if region_code!=1501 || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
*Drop Callao 
eststo:melogit cit_req eg_P10_someexp per_civic if region_code!=7 || region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic if region_code!=7 || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P10_someexp##c.per_civic eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 

esttab using tableA14.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A15. Voter mobilization: Party connections, civil society strength******
eststo:mixed polact_moreac_rowmean partmovmemb per_civic || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic  || region_code: ,  stddev cluster(region_code)
estat icc
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)

esttab using tableA15.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A16. Citizens' request: Party connections, civil society strength******
eststo:melogit cit_req partmovmemb per_civic || region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA16.rtf, replace constant aic bic b(3) scalars(ll) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A17. Voter mobilization: Party connections, civil society strength (exclusion of Lima Metropolitana or Callao)******
*Drop Lima Metropolitana 
eststo:mixed polact_moreac_rowmean partmovmemb per_civic if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic if region_code!=1501  || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  stddev cluster(region_code)
*Drop Callao
eststo:mixed polact_moreac_rowmean partmovmemb per_civic if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev cluster(region_code)

esttab using tableA17.rtf, replace constant aic bic b(3) scalars(ll) transform(ln*: exp(@) exp(@)) se
eststo clear

******Table A18. Citizens' request: Party connections, civil society strength (exclusion of Lima Metropolitana or Callao)******
*Drop Lima Metropolitana 
eststo:melogit cit_req partmovmemb per_civic if region_code!=1501 || region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic if region_code!=1501 || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
*Drop Callao
eststo:melogit cit_req partmovmemb per_civic if region_code!=7 || region_code: , vce(cluster region_code)
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic if region_code!=7  || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7  || region_code: ,  vce(cluster region_code) 

esttab using tableA18.rtf, replace constant aic bic scalars(ll) b(3) se
eststo clear

****Table A19. Voter mobilization and citizens' requests: Political connections, strength of civil society (full models reported)****
eststo:mixed polact_moreac_rowmean eg_P14_someexp per_civic || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req eg_P14_someex per_civic || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA19.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A20. Voter mobilization: Political connections, strength of civil society (exclusion of Lima Metropolitana or Callao)****
*Drop Lima Metropolitana
eststo:mixed polact_moreac_rowmean eg_P14_someexp per_civic if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser if region_code!=1501 || region_code: ,   stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: ,   stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,   stddev cluster(region_code)
*Drop Callao
eststo:mixed polact_moreac_rowmean eg_P14_someexp per_civic if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser if region_code!=7 || region_code: ,   stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=7 || region_code: ,   stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.per_civic eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,   stddev cluster(region_code)

esttab using tableA20.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A21. Citizens' request: Political connections, strength of civil society (exclusion of Lima Metropolitana or Callao)****
*Drop Lima Metropolitana
eststo:melogit cit_req eg_P14_someex per_civic if region_code!=1501 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic if region_code!=1501  || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser if region_code!=1501  || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A if region_code!=1501 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands  pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
*Drop Callao
eststo:melogit cit_req eg_P14_someex per_civic  if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic  if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser  if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A  if region_code!=7 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.per_civic eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap  if region_code!=7 || region_code: ,  vce(cluster region_code) 

esttab using tableA21.rtf, replace constant aic bic scalars(ll) b(3) se
eststo clear

****Table A22. Citizens' request and voter mobilization: Party connections, electoral volatility (last two elections)****
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.vol_el_vol_10_14 || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.vol_el_vol_10_14 eg_P14_someexp eg_P10_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap|| region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.vol_el_vol_10_14 || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA22.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A23. Citizens' request and voter mobilization: Party connections, electoral volatility (mean volatility)****
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.mean_elvol || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.mean_elvol eg_P14_someexp eg_P10_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.mean_elvol eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.mean_elvol || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.mean_elvol eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.partmovmemb##c.mean_elvol eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA23.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A24. Citizens' request and voter mobilization: Party connections, electoral volatility (exclusion of Lima Metropolitana or Callao)****
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=1501 || region_code: , stddev  cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=1501 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.mean_elvol eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.mean_elvol eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.vol_el_vol_10_14 eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=7 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.partmovmemb##c.mean_elvol eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.partmovmemb##c.mean_elvol eg_P10_someexp eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 

esttab using tableA24.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A25. Citizens' request and voter mobilization: Political connections, electoral volatility (last two elections)****
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.vol_el_vol_10_14 || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp ///
partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.vol_el_vol_10_14 || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb  eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 


esttab using tableA25.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A26. Citizens' request and voter mobilization: Political connections, electoral volatility (mean electoral volatility)****
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.mean_elvol || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.mean_elvol eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: , stddev  cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.mean_elvol || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA26.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A27.  Citizens' request and voter mobilization: Political connections, electoral volatility (exclusion of Lima Metropolitana or Callao)****
*Drop Lima Metropolitana
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  stddev   cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  stddev   cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
*Drop Callao
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev   cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.vol_el_vol_10_14 eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.eg_P14_someexp##c.mean_elvol eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev  cluster(region_code)
eststo:melogit cit_req i.eg_P14_someexp##c.mean_elvol eg_P10_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 

esttab using tableA27.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A28. Citizens' request and voter mobilization: Civil society connections, electoral volatility (last two elections)****
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.vol_el_vol_10_14 || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: ,  stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp ///
partmovmemb eg_gender  eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.vol_el_vol_10_14 || region_code: , vce(cluster region_code) 
estat icc
eststo:melogit cit_req i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp partmovmemb eg_gender  eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA28.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A29. Citizens' request and voter mobilization: Civil society connections, electoral volatility (mean volatility)****
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.mean_elvol || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , stddev cluster(region_code)
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.mean_elvol eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: , stddev cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.mean_elvol || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A || region_code: , vce(cluster region_code) 
eststo:melogit cit_req i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  vce(cluster region_code) 

esttab using tableA29.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A30. Citizens' request and voter mobilization: Civil society connections, electoral volatility (exclusion of Lima Metropolitana or Callao)****
*Drop Lima Metrpolitana
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp partmovmemb ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  stddev  cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb ///
eg_gender eg_ed_univ  years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=1501 || region_code: ,  vce(cluster region_code) 
*Drop Callao
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev  cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.vol_el_vol_10_14 eg_P14_someexp eg_P14_someexp partmovmemb eg_gender eg_ed_univ years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 
eststo:mixed polact_moreac_rowmean i.eg_P10_someexp##c.mean_elvol eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  stddev cluster(region_code)
eststo:melogit cit_req i.eg_P10_someexp##c.mean_elvol eg_P14_someexp partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser ///
i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap if region_code!=7 || region_code: ,  vce(cluster region_code) 

esttab using tableA30.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear

****Table A31. Regional interactions with composite measure of brokerage****
eststo:mixed comp_brokerage i.eg_P10_someexp##c.per_civic eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:mixed comp_brokerage i.partmovmemb##c.per_civic eg_P10_someexp eg_P14_someexp ///
eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:mixed comp_brokerage i.eg_P14_someexp##c.per_civic eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
mean_elvol ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: ,  stddev cluster(region_code)
eststo:mixed comp_brokerage i.partmovmemb##c.mean_elvol eg_P10_someexp ///
eg_P14_someexp eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: ,  stddev cluster(region_code)
eststo:mixed comp_brokerage i.eg_P14_someexp##c.mean_elvol eg_P10_someexp ///
partmovmemb eg_gender eg_ed_univ  years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands  pim_cap || region_code: , stddev  cluster(region_code)
eststo:mixed comp_brokerage i.eg_P10_someexp##c.mean_elvol eg_P14_someexp ///
partmovmemb eg_gender eg_ed_univ years_govreg cit_ser i.eg_P9 i.eg_P8A ///
per_civic ln_PBI_cap new_pop_2015_thousands pim_cap || region_code: , stddev cluster(region_code)

esttab using tableA31.rtf, replace constant aic bic scalars(ll) b(3) transform(ln*: exp(@) exp(@)) se
eststo clear


**************************************************************************************************************************
***How to construct the variables from other sources (all variables for analysis are available in the replication data set)***
**************************************************************************************************************************


*Civil society strength (From ENAHO 2015 Downloaded from http://webinei.inei.gob.pe/anda_inei/index.php/catalog/276/get_microdata)

*use "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/INEI/498-Modulo84_new/enaho01-2015-800a.dta"

*destring ubigeo, replace

*gen Region=0
*replace Region=1 if ubigeo<20000
*replace Region=2 if ubigeo>19999 & ubigeo<30000
*replace Region=3 if ubigeo>29999 & ubigeo<40000
*replace Region=4 if ubigeo>39999 & ubigeo<50000
*replace Region=5 if ubigeo>49999 & ubigeo<60000
*replace Region=6 if ubigeo>59999 & ubigeo<70000
*replace Region=7 if ubigeo>69999 & ubigeo<80000
*replace Region=8 if ubigeo>79999 & ubigeo<90000
*replace Region=9 if ubigeo>89999 & ubigeo<100000
*replace Region=10 if ubigeo>99999 & ubigeo<110000
*replace Region=11 if ubigeo>109999 & ubigeo<120000
*replace Region=12 if ubigeo>119999 & ubigeo<130000
*replace Region=13 if ubigeo>129999 & ubigeo<140000
*replace Region=14 if ubigeo>139999 & ubigeo<150000
*replace Region=15 if ubigeo>149999 & ubigeo<160000
*replace Region=1501 if Region==15 & ubigeo>150000 & ubigeo<150200

*replace Region=16 if ubigeo>159999 & ubigeo<170000
*replace Region=17 if ubigeo>169999 & ubigeo<180000
*replace Region=18 if ubigeo>179999 & ubigeo<190000
*replace Region=19 if ubigeo>189999 & ubigeo<200000
*replace Region=20 if ubigeo>199999 & ubigeo<210000
*replace Region=21 if ubigeo>209999 & ubigeo<220000
*replace Region=22 if ubigeo>219999 & ubigeo<230000
*replace Region=23 if ubigeo>229999 & ubigeo<240000
*replace Region=24 if ubigeo>239999 & ubigeo<250000
*replace Region=25 if ubigeo>249999 & ubigeo<260000


**NEW VARIABLES for Associations and clubs**
*gen enaho_sports=p801_1

*gen enaho_parties=p801_2
*recode enaho_parties(2=1) if p801_2==2

*gen enaho_cultural=p801_3
*recode enaho_cultural(3=1) if p801_3==3

*gen enaho_neighbor=p801_4
*recode enaho_neighbor(4=1) if p801_4==4

*gen enaho_rondacamp=p801_5
*recode enaho_rondacamp(5=1) if p801_5==5

*gen enaho_irrigation=p801_6
*recode enaho_irrigation(6=1) if p801_6==6

*gen enaho_professionals=p801_7
*recode enaho_professionals(7=1) if p801_7==7

*gen enaho_workers=p801_8
*recode enaho_workers(8=1) if p801_8==8

*gen enaho_mothers=p801_9
*recode enaho_mothers(9=1) if p801_9==9

*gen enaho_padresdefam=p801_10
*recode enaho_padresdefam(10=1) if p801_10==10

*gen enaho_vasodeleche=p801_11
*recode enaho_vasodeleche(11=1) if p801_11==11

*gen enaho_comedorpop=p801_12
*recode enaho_comedorpop(12=1) if p801_12==12

*gen enaho_health=p801_13
*recode enaho_health(13=1) if p801_13==13

*gen enaho_participatorybudg=p801_14
*recode enaho_participatorybudg(14=1) if p801_14==14

*gen enaho_localcoor=p801_15
*recode enaho_localcoor(15=1) if p801_15==15

*gen enaho_campesina=p801_16
*recode enaho_campesina(16=1) if p801_16==16

*gen enaho_agriculture=p801_17
*recode enaho_agriculture(17=1) if p801_17==17

*gen enaho_other=p801_18
*recode enaho_other(18=1) if p801_18==18

*gen enaho_gen_part= .
*replace enaho_gen_part=1 if p801_19==0
*replace enaho_gen_part=0 if p801_19==19

*Participates in any association

*egen enaho_any_part=rowmean(enaho_sports enaho_parties enaho_cultural enaho_neighbor enaho_rondacamp enaho_irrigation enaho_professionals enaho_workers enaho_mothers enaho_padresdefam enaho_vasodeleche enaho_comedorpop enaho_health enaho_participatorybudg enaho_localcoor enaho_campesina enaho_agriculture enaho_other)

*replace enaho_any_part=1 if  enaho_any_part>0 &  enaho_any_part<.

**Any organization except for political parties
*egen enaho_not_parties_any_part=rowmean(enaho_sports enaho_cultural enaho_neighbor enaho_rondacamp enaho_irrigation enaho_professionals enaho_workers enaho_mothers enaho_padresdefam enaho_vasodeleche enaho_comedorpop enaho_health enaho_participatorybudg enaho_localcoor enaho_campesina enaho_agriculture enaho_other)
*replace enaho_not_parties_any_part=1 if  enaho_not_parties_any_part>0 &  enaho_not_parties_any_part<.

*collapse enaho_not_parties_any_part, by(Region)

*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/replication data enaho civil society.dta", replace

*clear 

*use "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats.dta"

*merge m:1 Region using "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/replication data enaho civil society.dta", keepusing(enaho_not_parties_any_part)
*drop _merge


*Data on electoral volatility 
*Constructed Pedersen index (for each region and period, instuctions available from authors upon request) from source at Infogob-Jurado nacional de Elecciones (2017). [base de datos en línea]. https://infogob.jne.gob.pe/basedatos 


*Population in thousands (2015) Data on Population from INEI 2015 (from https://www.inei.gob.pe/media/MenuRecursivo/publicaciones_digitales/Est/Lib1251/Libro.pdf)
*Recode to include Lima Provincia (to be coded as Lima Metropolitana)

*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats.dta", replace

*clear

*Ln(GDP/capita) (2015) 
*Imported from https://www.inei.gob.pe/estadisticas/indice-tematico/producto-bruto-interno-por-departamentos-9089/
*import excel using "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Data/PBI PERU .xlsx", first

*rename B PBI_2015

*drop if PBI_2015==.

*gen region_code=0
*recode region_code(0=1) if Departamentos=="Amazonas"
*recode region_code(0=2) if Departamentos=="Ancash"
*recode region_code(0=3) if Departamentos=="Apurímac"
*recode region_code(0=4) if Departamentos=="Arequipa"
*recode region_code(0=5) if Departamentos=="Ayacucho"
*recode region_code(0=6) if Departamentos=="Cajamarca"
*recode region_code(0=7) if Departamentos=="Callao"
*recode region_code(0=8) if Departamentos=="Cusco"
*recode region_code(0=9) if Departamentos=="Huancavelica"
*recode region_code(0=10) if Departamentos=="Huánuco"
*recode region_code(0=11) if Departamentos=="Ica"
*recode region_code(0=12) if Departamentos=="Junín"
*recode region_code(0=13) if Departamentos=="La Libertad"
*recode region_code(0=14) if Departamentos=="Lambayeque"
*recode region_code(0=15) if Departamentos=="Lima Provincias"
*recode region_code(0=16) if Departamentos=="Loreto"
*recode region_code(0=17) if Departamentos=="Madre de Dios"
*recode region_code(0=18) if Departamentos=="Moquegua"
*recode region_code(0=19) if Departamentos=="Pasco"
*recode region_code(0=20) if Departamentos=="Piura"
*recode region_code(0=21) if Departamentos=="Puno"
*recode region_code(0=22) if Departamentos=="San Martín"
*recode region_code(0=23) if Departamentos=="Tacna"
*recode region_code(0=24) if Departamentos=="Tumbes"
*recode region_code(0=25) if Departamentos=="Ucayali"
*recode region_code(0=1501) if Departamentos=="Lima Metropolitana"

*tab Departamentos if region_code==0
*drop if Departamentos=="Lima"

*label variable PBI_2015 "PBI 2015"

*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/PBI Peru 2015.dta", replace

*clear

*use "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats.dta"

*merge m:1 region_code using "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/PBI Peru 2015.dta"

*drop _merge


*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats", replace

*clear

*Regional budget/capita (2015)
*PIM 2015 (imported from Ejecución del Presupuesto Público 2015 y Presupuesto Institucional de Apertura 2016 Reporte N° 01–2016–CG/EST La contraloria general de la republica, p. 12-13)

*Create stata file 
*import excel using "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Data/Presupuesto regional/Contraloria p12-13.xlsx", first

*gen region_code=0
*recode region_code(0=1) if Region=="Amazonas"
*recode region_code(0=2) if Region=="Ancash"
*recode region_code(0=3) if Region=="Apurímac"
*recode region_code(0=4) if Region=="Arequipa"
*recode region_code(0=5) if Region=="Ayacucho"
*recode region_code(0=6) if Region=="Cajamarca"
*recode region_code(0=7) if Region=="Callao"
*recode region_code(0=8) if Region=="Cusco"
*recode region_code(0=9) if Region=="Huancavelica"
*recode region_code(0=10) if Region=="Huánuco"
*recode region_code(0=11) if Region=="Ica"
*recode region_code(0=12) if Region=="Junín"
*recode region_code(0=13) if Region=="La Libertad"
*recode region_code(0=14) if Region=="Lambayeque"
*recode region_code(0=15) if Region=="Lima"
*recode region_code(0=16) if Region=="Loreto"
*recode region_code(0=17) if Region=="Madre de Dios"
*recode region_code(0=18) if Region=="Moquegua"
*recode region_code(0=19) if Region=="Pasco"
*recode region_code(0=20) if Region=="Piura"
*recode region_code(0=21) if Region=="Puno"
*recode region_code(0=22) if Region=="San Martín"
*recode region_code(0=23) if Region=="Tacna"
*recode region_code(0=24) if Region=="Tumbes"
*recode region_code(0=25) if Region=="Ucayali"
*recode region_code(0=1501) if Region=="Lima Metropolitana"

*drop if region_code==0

*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/PIM_2015.dta", replace

*clear

*use "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats.dta"
*merge m:1 region_code using "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/Empirical analysis/PIM_2015.dta", force
*drop _merge

*save "/Users/xcorag/Dropbox/Project No democracy without bureaucracy/Peru/replicationdata_Brokering_bureaucrats.dta", replace

